package com.thinqq.web.client.content.handler;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.KeyCodes;
import com.google.gwt.event.dom.client.KeyPressEvent;
import com.google.gwt.event.dom.client.KeyPressHandler;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.SuggestBox;

public class SearchBoxHandler implements ClickHandler, KeyPressHandler {
	private String searchString = "http://osearch.thinqq.com/system/app/pages/customSearch?q=$&scope=cse-goog_1703314421";
	private SuggestBox searchBox;
	public SearchBoxHandler(SuggestBox searchBox) {
		super();
		this.searchBox = searchBox;
	}
	@Override
	public void onClick(ClickEvent event) {
		Window.open(searchString.replace("$", searchBox.getValue()), "_self", "");
	}
	@Override
	public void onKeyPress(KeyPressEvent event) {
		if (event.getCharCode() == KeyCodes.KEY_ENTER) {
			Window.open(searchString.replace("$", searchBox.getValue()), "_self", "");
	        }


	}

}
